<template>
  <div class="app-container">
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="设备编号">
        <el-input placeholder="请输入设备编号" v-model.number="deviceid" clearable></el-input>
      </el-form-item>
      <el-form-item label="监测点">
        <el-input placeholder="请输入监测点" v-model.number="alarmdegree" clearable></el-input>
      </el-form-item>
      <el-form-item label="监测类型">
        <el-input placeholder="请输入监测类型" v-model.number="alarmdegree" clearable></el-input>
      </el-form-item>    
    </el-form>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
     <el-form-item label="时间">
        <el-date-picker v-model="selecttime" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getAlarmData">查询</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getAlarmData">导出excel</el-button>
      </el-form-item>
   </el-form>
   
   <div id="chart1"></div>

  </div>

</template>

<script>

import { GetHistoryAlarm } from "@/api/devicemanage/devicealarm";
export default {
  data () {
    return {
      deviceid: 1001,
      alarmdegree: 100,
      loading: false,
      datalist: null,
      page: 1,
      pagesize: 20,
      // 总条数
      total: 0,
      selecttime: [new Date(2021, 6, 10, 10, 10), new Date(2021, 11, 11, 10, 10)],  //选择的时间
    }
  },
  created () {

  },
  methods: {
    // 获取历史报警数据
    getAlarmData () {
      this.loading = true;
      GetHistoryAlarm(this.deviceid, this.parseTime(this.selecttime[0]), this.parseTime(this.selecttime[1]), this.alarmdegree, this.page, this.pagesize).then(response => {
        console.log(response)
        const res = response.data;
        this.datalist = res.data;
        this.total = res.dataCount;
        this.loading = false;
      }).catch((ex) => {
        this.msgError(ex.message);
        this.loading = false;
      });
    },
    //分页查询
    getPageList () {
      GetHistoryAlarm(this.deviceid, this.parseTime(this.selecttime[0]), this.parseTime(this.selecttime[1]), this.alarmdegree, this.page, this.pagesize).then(response => {
        console.log(response)
        const res = response.data;
        this.datalist = res.data;
        this.total = res.dataCount;
        this.loading = false;
      }).catch((ex) => {
        this.msgError(ex.message);
        this.loading = false;
      });
    }

  }
}
</script>

<style>
</style>